#ifndef TYPES_H
#define TYPES_H

//max no of chars per line
#define MAX_CODE_LENGTH 256
//no of params that a function macro can take
#define MAX_PARAM 1024
//max length of each arg in a macro call
#define PARAM_LENGTH 1024
//max number of macros that can be defined
#define MAX_MACRO 1024

#define FILENAME_SIZE 256

#define DEBUG 0

/*
 * Opcode mneumonics and other keywords
 * Each line of code should contain one of these
 * Attention: enum keyword depends on these
 * These values are also the real opcode to be put in the microcode..
 */
enum opcode {NOP, ADD, MULT, AND, SWC, CMP, NOT, GOF, JMP, JMN, JMZ, STORE, LOAD, SLEEP};
typedef enum opcode opcode;

/*
 * Contains function call params and args.
 * For each function definition, a func_call structure is created and the params fields are filled. 
 * We access this global structure by a pointer from all the lines contained in the function definition (in every element of func_content). 
 *
 * Then at every function call, the 'args' fields are filled with current arguments.
 * W: there is only one copy of this thing per function and all function calls share that copy.
 */
typedef struct {
	char params[MAX_PARAM][MAX_CODE_LENGTH];
	char args[MAX_PARAM][MAX_CODE_LENGTH];
	int nparam;
}func_call, *func_callp;

/*
 * other keywords used in the language.
 * Warning: these values depends on enum opcode. 
 */
enum keyword {macro = LOAD+1,end,start,define};
typedef enum keyword keyword;



/*
 * Instruction
 * params: noms des parametres formels
 * args: ceux qui sont passes comme arg lors d'un appel de macro
 * fc: if this is a inline instruction, than it has a pointer to a func_call structure. otherwise it is set to NULL
 * line_no: instruction number. not the line number in the src
 * source_code_line_no: 
 */

typedef struct instr instr;
typedef struct instr * instrp;

struct instr{
    char code[MAX_CODE_LENGTH];
    func_callp fc;	//only used for macro content array
    instrp next;
    int line_no;
    int source_code_line_no;
};


#endif
